/*
 * CreationState.hpp
 *
 *  Created on: 11-01-2011
 *      Author: Przemek
 */

#pragma once

#include "CreateToolState.hpp"
#include "world/Element.hpp"
#include "pch.hpp"

/*
 * State of creation new world elements. It contains a tool and currently added Element instance.
 */
class CreationState
{
	private:
		boost::shared_ptr<CreateToolState> createTool;
		boost::shared_ptr<Element> toAdd;

	public:
		void clearCreateTool();
		void setCreateTool(CreateToolState* createTool);
		bool anyCreateTool() const;
		const CreateToolState* getCreateTool() const;
		// move currently toAdd element so that it's center is in the point
		void moveCenteredTo(const Vector& point);
		void moveAnchoredToGrid(const Vector& point);
		bool anyToAdd() const;
		Element* getToAdd();
		// add element to world if not colliding, if succeeded create other toAdd element of the same type
		void tryAddElementToWorld();

	private:
		void resetToAdd();
		// returns left corner position of a grid anchored point
		Vector getAnchoredToGrid(const Vector& point) const;
};
